package com.example.drools_springboot_demo.model;

import java.io.*;
import java.math.BigDecimal;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

/**
 * Created by DongChenchen on 2018/5/2 0002
 * 一个平台--多个交易记录(单币)
 *
 * 暂时 只根据币的多少  判定需不需要回流
 */
public class ExchangeTransaction implements Cloneable,Serializable{
    private List<Transaction> transactions;//交易记录  用于寻找最近交易最多的平台
    private String exchange;//交易平台
    private String coin_code;//交易平台
    //回流判定
    private BigDecimal money_sum_threshold;//用户自己设定的资金固定值(特定平台)
    private BigDecimal coin_sum_threshold;//用户自己设定的数字货币固定值(特定平台)
    private BigDecimal money_sum;//用户自己的资金(特定平台)
    private BigDecimal coin_sum;//用户自己的数字货币(特定平台)

    private Integer money_coin;//计算的中间变量  0：钱多币少   1：钱少币多  -1:该平台不需要回流
//    private BigDecimal money_scale;//计算的中间变量  （实际的钱-阀值）/阀值  多少的程度
    private BigDecimal coin_scale;//计算的中间变量
    private List<ExchangeTransaction> inverse_exchanges;//计算的中间变量 与当前交易所 成反比的交易所  按反比值从大到小排序

    private Boolean has_pair;//是否与反比例交易所已经配对成功

    //吃单判定
    private Order order;



    public List<Transaction> getTransactions() {
        return transactions;
    }

    public void setTransactions(List<Transaction> transactions) {
        this.transactions = transactions;
    }

    public String getExchange() {
        return exchange;
    }

    public void setExchange(String exchange) {
        this.exchange = exchange;
    }

    public BigDecimal getMoney_sum_threshold() {
        return money_sum_threshold;
    }

    public void setMoney_sum_threshold(BigDecimal money_sum_threshold) {
        this.money_sum_threshold = money_sum_threshold;
    }

    public BigDecimal getCoin_sum_threshold() {
        return coin_sum_threshold;
    }

    public void setCoin_sum_threshold(BigDecimal coin_sum_threshold) {
        this.coin_sum_threshold = coin_sum_threshold;
    }

    public BigDecimal getMoney_sum() {
        return money_sum;
    }

    public void setMoney_sum(BigDecimal money_sum) {
        this.money_sum = money_sum;
    }

    public BigDecimal getCoin_sum() {
        return coin_sum;
    }

    public void setCoin_sum(BigDecimal coin_sum) {
        this.coin_sum = coin_sum;
    }

    public Integer getMoney_coin() {
        return money_coin;
    }

    public void setMoney_coin(Integer money_coin) {
        this.money_coin = money_coin;
    }

//    public BigDecimal getMoney_scale() {
//        return money_scale;
//    }

//    public void setMoney_scale(BigDecimal money_scale) {
//        this.money_scale = money_scale;
//    }

    public BigDecimal getCoin_scale() {
        return coin_scale;
    }

    public void setCoin_scale(BigDecimal coin_scale) {
        this.coin_scale = coin_scale;
    }

    public List<ExchangeTransaction> getInverse_exchanges() {
        return inverse_exchanges;
    }

    public void setInverse_exchanges(List<ExchangeTransaction> inverse_exchanges) {
        this.inverse_exchanges = inverse_exchanges;
    }

    public Order getOrder() {
        return order;
    }

    public void setOrder(Order order) {
        this.order = order;
    }

    public Boolean getHas_pair() {
        return has_pair;
    }

    public void setHas_pair(Boolean has_pair) {
        this.has_pair = has_pair;
    }

    public String getCoin_code() {
        return coin_code;
    }

    public void setCoin_code(String coin_code) {
        this.coin_code = coin_code;
    }

    public Object deepClone() throws IOException,ClassNotFoundException{
        //将对象写到流里
        ByteArrayOutputStream bo=new ByteArrayOutputStream();
        ObjectOutputStream oo=new ObjectOutputStream(bo);
        oo.writeObject(this);
        //从流里读出来
        ByteArrayInputStream bi=new ByteArrayInputStream(bo.toByteArray());
        ObjectInputStream oi=new ObjectInputStream(bi);
        return(oi.readObject());
    }
}
